package whf.framework.meta;

import java.util.ArrayList;
import java.util.List;

import whf.framework.entity.Entity;
import whf.framework.meta.entity.Object;
import whf.framework.meta.service.ObjectService;
import whf.framework.meta.service.ObjectServiceImp;

/**
 * @author wanghaifeng
 *
 */
public class DbMetaParser implements IMetaParser {

	public List<Meta> listMetas() throws MetaParserException {
		List<Meta> list = new ArrayList<Meta>();
		try {
			ObjectService service = ObjectServiceImp.getObjectService();
			List<Object> objs = service.findAllWithoutLazy();
			for (Entity bo : objs) {
				Object obj = (Object) bo;
				list.add(obj.toMeta());
			}
		} catch (Exception e) {
			throw new MetaParserException(e);
		}
		return list;
	}

	public static void main(String[] args) throws Exception {
		DbMetaParser p = new DbMetaParser();
		List<Meta> list = p.listMetas();
		for (Meta m : list) {
			System.out.println(m);
		}
	}
}
